/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package bonus;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;

/**
 *
 * @author Administrator
 */
public class DBConnector {

    public static synchronized Connection getConnection() throws SQLException,
            FileNotFoundException, IOException {
        Properties props = new Properties();
        InputStream is = DBConnector.class.getResourceAsStream("resource/database.properties");
        props.load(is);

        String drivers = props.getProperty("jdbc.drivers");
        if (drivers != null) {
            System.setProperty("jdbc.drivers", drivers);
        }
        String url = props.getProperty("jdbc.url");
        String user = props.getProperty("jdbc.user");
        String password = props.getProperty("jdbc.password");
        is.close();
        return DriverManager.getConnection(url, user, password);
    }

    /*public static void closeConnection() throws SQLException {
        conn.close();
    }*/
}